package com.igeek.ch03summary;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * TODO
 *
 * @author xuxin
 * @since 2024/5/22
 */
@Component
public class People implements InitializingBean, DisposableBean {
    @Value("王五")
    private String name;

    public People() {
    }

    public People(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    public String toString() {
        return "People{name = " + name + "}";
    }

    @PostConstruct
    public void postConstruct(){
        System.out.println("PostConstruct 开始初始化");
    }

    @PreDestroy
    public void preDestroy(){
        System.out.println("PreDestroy 开始销毁");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("destroy 销毁");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("afterPropertiesSet 初始化");
    }
}
